﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ListProject.aspx.cs" Inherits="WEB.APP.Modules.List.ListProject" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<%@ Register Src="~/Controls/List/ProjectForm.ascx" TagName="WindowEditor" TagPrefix="uc" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script language="javascript" type="text/javascript">
        var RendererProjectType = function (value, idxclomn, record) {
            switch (value) {
                case 1:
                    return 'Database Design and Development';
                case 2:
                    return 'Software Development';
                case 3:
                    return 'Mobile Application';
                case 4:
                    return 'Web Application';
                case 5:
                    return 'Systems Analysis and Design';
                case 6:
                    return 'Website Design and Development';
                case 7:
                    return 'Systems Administration';
                case 8:
                    return 'Operating System Development';
                case 9:
                    return 'Web Systems development';
                default:
                    return value;
            }
        }
        var RendererProjectSize = function (value, idxclomn, record) {
            switch (value) {
                case 0:
                    return 'Easy';
                case 1:
                    return 'Medium complexity';
                case 2:
                    return 'Complex';
                default:
                    return value;
            }
        }
        var ApplyFind = function () {
            hfKeyword.setValue(txtKeyword.getValue());
            paddingBar.changePage(0);
        }

        var renderClientId = function (value, idxclomn, record) {
            var string = '0000' + value.toString();
            return 'C' + string.substring(string.length - 4, string.length)
        }

        var renderPROJECTId = function (value, idxclomn, record) {
            var string = '0000' + value.toString();
            return 'P' + string.substring(string.length - 4, string.length)
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <ext:Hidden runat="server" ID="hfIsEdit" />
    <ext:Hidden runat="server" ID="hfIsDelete" />
    <ext:Hidden runat="server" ID="hfKeyword" />
    <ext:Hidden runat="server" ID="hdScreenDetailID" Text="0" />
    <ext:Store ID="storeMain" runat="server" OnRefreshData="storeMain_OnRefreshData"
        WarningOnDirty="false">
        <Proxy>
            <ext:PageProxy />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="ProjectId">
                <Fields>
                    <ext:RecordField Name="ProjectId" />
                    <ext:RecordField Name="ClientId" />
                    <ext:RecordField Name="ProjectName" />
                    <ext:RecordField Name="Expertise" />
                    <ext:RecordField Name="ProjectType" />
                    <ext:RecordField Name="ProjectDesc" />
                    <ext:RecordField Name="ProjectYear" />
                    <ext:RecordField Name="ProjectSize" />
                    <ext:RecordField Name="NumberStudent" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="start" Value="0" Mode="Raw" />
            <ext:Parameter Name="limit" Value="50" Mode="Raw" />
        </BaseParams>
    </ext:Store>
    <ext:Viewport ID="Viewport1" runat="server" Layout="border">
        <Items>
            <ext:GridPanel ID="grdMain" runat="server" StripeRows="true" TrackMouseOver="true"
                AutoExpandColumn="Expertise" Border="false" Region="Center" StoreID="storeMain">
                <TopBar>
                    <ext:Toolbar ID="tbMain" runat="server">
                        <Items>
                            <ext:Button ID="btnAdd" runat="server" Text="Add" Icon="TableAdd">
                                <DirectEvents>
                                    <Click OnEvent="btnAdd_Click" />
                                </DirectEvents>
                            </ext:Button>
                            <ext:ToolbarSeparator runat="server" ID="tbsAdd" />
                            <ext:Button ID="btnDelete" runat="server" Text="Delete" Icon="TableRowDelete">
                                <Listeners>
                                    <Click Handler="deleteRows(#{grdMain});" />
                                </Listeners>
                            </ext:Button>
                            <ext:ToolbarFill />
                            <ext:TextField ID="txtKeyword" runat="server" EmptyText="Search">
                                <Listeners>
                                    <SpecialKey Handler="if(e.getKey() == Ext.EventObject.ENTER) { ApplyFind(); }" />
                                </Listeners>
                            </ext:TextField>
                            <ext:ToolbarSpacer />
                            <ext:Button ID="btnFind" runat="server" Text="Search" Icon="Find" FormBind="true">
                                <Listeners>
                                    <Click Fn="ApplyFind" />
                                </Listeners>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <ColumnModel ID="ColumnModel1" runat="server" DefaultSortable="False">
                    <Columns>
                        <ext:RowNumbererColumn />
                        <ext:Column ColumnID="ProjectId" DataIndex="ProjectId" Header="Project Id">
                        <Renderer Fn="renderPROJECTId" /> 
                        </ext:Column>
                        <ext:Column ColumnID="ClientId" DataIndex="ClientId" Header="Client Id">
                            <Renderer Fn="renderClientId"/>
                            </ext:Column>
                        <ext:Column ColumnID="ProjectName" DataIndex="ProjectName" Header="Project Name"/>
                        <ext:Column ColumnID="Expertise" DataIndex="Expertise" Header="Expertise"/>
                        <ext:Column ColumnID="ProjectType" DataIndex="ProjectType" Header="Project Type">
                            <Renderer Fn="RendererProjectType" />
                        </ext:Column>
                        <ext:Column ColumnID="ProjectSize" DataIndex="ProjectSize" Header="Project Size">
                            <Renderer Fn="RendererProjectSize" />
                        </ext:Column>
                        <%--<ext:Column ColumnID="ProjectDesc" DataIndex="ProjectDesc" Header="Project Desc"/>--%>
                        <ext:Column ColumnID="ProjectYear" DataIndex="ProjectYear" Header="Project Year"/>
                        <ext:Column ColumnID="NumberStudent" DataIndex="NumberStudent" Header="Number Student"/>
                    </Columns>
                </ColumnModel>
                <Listeners>
                    <RowDblClick Handler="this.getSelectionModel().selectRow(rowIndex); viewWinDetail(#{grdMain});" />
                    <RowContextMenu Handler="e.preventDefault(); #{RowContextMenu}.dataRecord = this.store.getAt(rowIndex);#{RowContextMenu}.showAt(e.getXY());this.getSelectionModel().selectRow(rowIndex);" />
                </Listeners>
                <SelectionModel>
                    <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true" />
                </SelectionModel>
                <KeyMap>
                    <ext:KeyBinding>
                        <Keys>
                            <ext:Key Code="DELETE" />
                        </Keys>
                        <Listeners>
                            <Event Handler="deleteRows(#{grdMain});" />
                        </Listeners>
                    </ext:KeyBinding>
                </KeyMap>
                <View>
                    <ext:GridView MarkDirty="false">
                    </ext:GridView>
                </View>
                <BottomBar>
                    <ext:PagingToolbar ID="paddingBar" StoreID="storeMain" runat="server" PageSize="50"
                        DisplayInfo="true" EmptyMsg="No data found" DisplayMsg="{0} - {1} in {2}">
                        <Items>
                            <ext:ToolbarSeparator />
                            <ext:Checkbox runat="server" ID="cbProjectValid" BoxLabel="Project Valid">
                                <Listeners>
                                    <Check Handler="paddingBar.changePage(0);" />
                                </Listeners>
                            </ext:Checkbox>
                        </Items>
                    </ext:PagingToolbar>
                </BottomBar>
            </ext:GridPanel>
        </Items>
    </ext:Viewport>
    <uc:WindowEditor ID="WindowEditor" runat="server" />
    <ext:Menu ID="RowContextMenu" runat="server">
        <Items>
            <ext:MenuItem ID="mnEdit" runat="server" Text="Edit" Icon="TableEdit">
                <Listeners>
                    <Click Handler="viewWinDetail(#{grdMain});" />
                </Listeners>
            </ext:MenuItem>
            <ext:MenuItem ID="MenuItem1" runat="server" Text="View Report" Icon="TableEdit">
                <Listeners>
                    <Click Handler="ViewDetail(#{grdMain});" />
                </Listeners>
            </ext:MenuItem>
            <ext:MenuItem ID="mnDelete" runat="server" Text="Delete" Icon="Delete">
                <Listeners>
                    <Click Handler="deleteRows(#{grdMain});" />
                </Listeners>
            </ext:MenuItem>
        </Items>
    </ext:Menu>
    </form>
</body>
</html>
